/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import model.Artist;


public class ArtistCellRenderer extends DefaultTableCellRenderer {
    private Object artistStr;
    @Override
    public Component getTableCellRendererComponent(
            JTable table, Object value, boolean isSelected,
            boolean hasFocus, int row, int column) {
        if (value instanceof Artist) {
            Artist a = (Artist)value;
            //pat3group: sky - Συνθέτω το ονοματεπώνυμο - ψευδώνυμο καλλιτέχνη
            String str="";
            try {
                str = (a.getArtistArtname().length()==0)?"":", ("+a.getArtistArtname()+")";
            } catch (Exception e) {
                System.out.println("Artist Artname null");
            }
            try {
                artistStr = a.getArtistLname()+" "+a.getArtistFname()+str;
            } catch (Exception e) {
                System.out.println("artist string error");
            }
            
        }
        return super.getTableCellRendererComponent(table, artistStr, isSelected, hasFocus, row, column);
    }
}